package com.ruoyi.project.naming.sancaianalysis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.naming.sancaianalysis.domain.SancaiAnalysis;
import com.ruoyi.project.naming.sancaianalysis.service.ISancaiAnalysisService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 三才配置Controller
 * 
 * @author shixiangwen
 * @date 2022-04-22
 */
@Controller
@RequestMapping("/naming/sancaianalysis")
public class SancaiAnalysisController extends BaseController
{
    private String prefix = "naming/sancaianalysis";

    @Autowired
    private ISancaiAnalysisService sancaiAnalysisService;

    @RequiresPermissions("naming:sancaianalysis:view")
    @GetMapping()
    public String sancaianalysis()
    {
        return prefix + "/sancaianalysis";
    }

    /**
     * 查询三才配置列表
     */
    @RequiresPermissions("naming:sancaianalysis:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SancaiAnalysis sancaiAnalysis)
    {
        startPage();
        List<SancaiAnalysis> list = sancaiAnalysisService.selectSancaiAnalysisList(sancaiAnalysis);
        return getDataTable(list);
    }

    /**
     * 导出三才配置列表
     */
    @RequiresPermissions("naming:sancaianalysis:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SancaiAnalysis sancaiAnalysis)
    {
        List<SancaiAnalysis> list = sancaiAnalysisService.selectSancaiAnalysisList(sancaiAnalysis);
        ExcelUtil<SancaiAnalysis> util = new ExcelUtil<SancaiAnalysis>(SancaiAnalysis.class);
        return util.exportExcel(list, "sancaianalysis");
    }

    /**
     * 新增三才配置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存三才配置
     */
    @RequiresPermissions("naming:sancaianalysis:add")
    @Log(title = "三才配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SancaiAnalysis sancaiAnalysis)
    {
        return toAjax(sancaiAnalysisService.insertSancaiAnalysis(sancaiAnalysis));
    }

    /**
     * 修改三才配置
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SancaiAnalysis sancaiAnalysis = sancaiAnalysisService.selectSancaiAnalysisById(id);
        mmap.put("sancaiAnalysis", sancaiAnalysis);
        return prefix + "/edit";
    }

    /**
     * 修改保存三才配置
     */
    @RequiresPermissions("naming:sancaianalysis:edit")
    @Log(title = "三才配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SancaiAnalysis sancaiAnalysis)
    {
        return toAjax(sancaiAnalysisService.updateSancaiAnalysis(sancaiAnalysis));
    }

    /**
     * 删除三才配置
     */
    @RequiresPermissions("naming:sancaianalysis:remove")
    @Log(title = "三才配置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sancaiAnalysisService.deleteSancaiAnalysisByIds(ids));
    }
}
